<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="${ctx}/js/ext-3.3.0/resources/css/ext-all.css"/>
<link href="${ctx}/css/friendlist.css" media="screen" rel="stylesheet" type="text/css" />

<link href="${ctx}/css/css51.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx}/js/ext-3.3.0/ext-base.js"></script>
<script type="text/javascript" src="${ctx}/js/ext-3.3.0/ext-all.js"></script>
<script type="text/javascript" src="${ctx}/js/ext-3.3.0/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="${ctx}/js/ajaxfileupload.js"></script>
<title>后台用户管理</title>
<script type="text/javascript">
	var cityList = [
		<#list cityList as city>
			<#if city_has_next>
				['${city.cityname!}','${city.cityno!}'],
			<#else>
				['${city.cityname!}','${city.cityno!}']
			</#if>
		</#list>
	];
	var roleList = [
		<#list roleList as role>
			<#if role_has_next>
				['${role.name!}','${role.id?c}'],
			<#else>
				['${role.name!}','${role.id?c}']
			</#if>
		</#list>
	];
	//根据cityNo 获取cityName
	function getCityName(cityNo){
		for (var i = 0; i < cityList.length; i++) {
			if (cityNo == cityList[i][1]) {
				return cityList[i][0];
			}
		}
		return "";
	}
	//获取用户管理城市
	var userCityList = new Array(new Array("","全部"));
	function getCityListByUser(){
		var cityNo = "${SESSION_USER.cityNo!}";
		if(cityNo != null && cityNo != ""){
			cityNo = cityNo.substring(1,cityNo.length - 1);
			var listCity = cityNo.split(",");
			for(var i = 0; i < listCity.length; i++){
				userCityList[i+1] = new Array(listCity[i],getCityName(listCity[i]));
			}
		}
		return userCityList;
	}
	getCityListByUser();
	String.prototype.replaceAll = function(s1,s2) {
	   	return this.replace(new RegExp(s1,"gm"),s2);
	}
	//批量删除
	function listDelete(id){
		Ext.Msg.confirm('信息','确定要删除?',function(btn){
			if(btn == "yes"){
				$.ajax({
	    			url : "${ctx}/crmuser/ajax/deleteByIds",
	 				data:{
	    				ids:id
	 				},
	 				type:"post",
	 				success:function(data){
	 					if(data == 1){
	 						alert("操作成功");
	 						Ext.getCmp("grid2").getStore().removeAll();
		      				Ext.getCmp("grid2").getStore().load("${ctx}/crmuser/ajax/list");
	 						//document.location.reload();
	 					}else{
	 						alert("操作失败");
	 					}
	 				}
	 			});
			}
 		})
	}
	//全选 取消全选
	//params : all 全选复选框
	function reverseAllSelect(all){
		if(all.type == "checkbox" && all.checked == true){
			isReverseAllSelect(true);
		}else{
			isReverseAllSelect(false);
		}
	}
	function isReverseAllSelect(isSelect){
		var items = document.getElementsByTagName("input");
		for(var i=0;i<items.length;i++){
		    if(items[i].type == "checkbox"){
		        items[i].checked = isSelect;
		    }
	    }
	}
	//为复选框赋默认值
  	function cboInit(cboName,valueSet){
		var cbo = document.getElementsByName(cboName);
		for(var i = 0;i < cbo.length;i++){
		    if(valueSet.indexOf("," + cbo[i].value + ",") != -1){
		    	cbo[i].checked = "checked";
		    }else{
				cbo[i].checked = "";
			}
		}
	}
	//获取复选框被选中值
  	function getCheckedValue(cboName){
  		var value = ",";
		var cbo = document.getElementsByName(cboName);
		for(var i = 0;i < cbo.length;i++){
		    if(cbo[i].checked){
		    	value += cbo[i].value + ",";
		    }
	  	}
	  	return value == "," ? "" : value;
  	}
	var list;
	function ajaxAddOrUpdate(){
		var cboCityNo = getCheckedValue("cboCityNo");
		if(getCheckedValue("cboCityNo") == ""){
			alert("请选择城市");
			return;
		}
		setWinStyle(win,false);
		$.ajax({
    		url : "${ctx}/crmuser/ajax/add",
 			data:{
    			id:entity.id,
    			userName:encodeURIComponent($("#userName").val()),
    			userTrueName:$("#userTrueName").val(),
    			userPass:entity.userPass,
    			linkTel:$("#linkTel").val(),
    			mobilePhone:$("#mobilePhone").val(),
    			email:$("#email").val(),
    			roleIds:entity.roleIds,
    			//roleName:$("#roleName").val(),
    			cityNo:cboCityNo,
    			//cityName:$("#cityName").val(),
				userCityNo:$("#userCityNo").val(),
				//lastLoginTimeString:entity.lastLoginTimeString,
    			state:$("#state").val()
 			},
 			type:"post",
 			success:function(data){
				setWinStyle(win,true);
 				if(data == 1){
 					Ext.MessageBox.alert("提示","操作成功！");
 					store.reload();
 				}else if(data == -1){
					Ext.MessageBox.alert("用户名重复","该用户已存在！");
				}else if(data == 0){
 					Ext.MessageBox.alert("提示","操作失败！");
 				}
 			}
 		});
    }
	function setWinStyle(extWin,isHide){
		$("#"+extWin.el.id).css("z-index",isHide == false ? 0 : 9003);
		if (isHide) {
			extWin.hide();
		}
	}
	function clearData(){
		$("#userName").val("");
		$("#userTrueName").val("");
		$("#cityNo").val("");
		$("#linkTel").val("");
		$("#mobilePhone").val("");
		$("#userCityNo").val("");
		$("#email").val("");
		$("#all").attr("checked",false);
	}
	var entity = {"id":0,"roleIds":"","userPass":"0","lastLoginTimeString":""};
	var win;
	var roleWin;//选择权限弹出窗口
	var saveCommand;
	function btnaddOrUpdateIssue_click(command,rowIndex,divId){
		//alert(Ext.getCmp("grid2").getBottomToolbar().cursor + 1);
//		//alert(win.contentEl);
//		if(divId != "friendSelecter"){
//			win = showWin("hello-win","nleft",200);
//			//$("#friendSelecter").hide();//$("#nleft").show();//win.height = 200;
//		}else{
//			win = showWin("role-win","friendSelecter",450);
//			//$("#friendSelecter").show();//$("#nleft").hide();//win.height = 450;
//		}
		cboInit("cboCityNo","");
		saveCommand = command;
		if(saveCommand == "add"){
			$("#userName").attr("readOnly","");
			entity.id = 0;
			entity.roleIds = "";
			entity.userPass = "0";
			entity.lastLoginTimeString = "";
			clearData();
		}else if(saveCommand.indexOf("edit") > -1){
			var tmp = list.getAt(rowIndex);
			$("#userName").attr("readonly","true");
			entity.id = tmp.get("id");
			entity.userPass = tmp.get("userPass");
			entity.lastLoginTimeString = tmp.get("lastLoginTime");
			entity.roleIds = tmp.get("roleIds");
			$("#cityNo").val(tmp.get("cityNo"));
			$("#userName").val(tmp.get("userName"));
			$("#userTrueName").val(tmp.get("userTrueName"));
			$("#linkTel").val(tmp.get("linkTel"));
			$("#mobilePhone").val(tmp.get("mobilePhone"));
			$("#email").val(tmp.get("email"));
			$("#state").val(tmp.get("state"));
			$("#userCityNo").val(tmp.get("userCityNo"));
			cboInit("cboCityNo",tmp.get("cityNo"));
		}
		if(!win){
			win = new Ext.Window({
				id:"win",
				el:"hello-win",
				title:"操作",
				layout:'fit',
				width:500,
				height:370,
				hidden:true,
				resizable:false,
				closeAction:'hide',
				plain: true,
				contentEl : "nleft",
		        buttons: [
		        		{text:'保存',handler:  function(){ajaxAddOrUpdate();}},
					    {text: '取消',handler: function(){win.hide();}
						}]
			});
		}
		win.show();
	}
	//返回已选角色html
	function getRoleHtml(roleId,roleName){
		return "<li id='"+roleId+"' class='fs_del'>" + 
				"<a class='fs_nor' hidefocus='true'>" + roleName + "</a>" + 
				"<a class='fs_state' title='删除' onclick='removeRoleHtml(" + roleId +" )'>删除</a>" + 
			"</li>";
	}
	//保存已选角色id,name
	var saveSelectRoleIds = "";
	//添加角色至已选角色
	function addRoleHtml(roleId,roleName){
		if(document.getElementById("frisel_"+roleId).className != "fs_selected"){
			saveSelectRoleIds += roleId + ",";
			$("#frisel_"+roleId).attr("class","fs_selected");
			$("#frisel_selectList").append(getRoleHtml(roleId,roleName));
		}
	}
	//移除已选角色
	function removeRoleHtml(roleId){
		saveSelectRoleIds = saveSelectRoleIds.replace(roleId + ",", "");
		if(saveSelectRoleIds.length == 1){
			saveSelectRoleIds = "";
		}
		$("#frisel_" + roleId).attr("class", "");
		$("#" + roleId).remove();
	}
	var saveUserId = 0;
	//根据用户id 更新用户角色
	function updateRoleIdsById(){
		setWinStyle(roleWin,false);
		//saveSelectRoleIds = saveSelectRoleIds == "" ? "" : saveSelectRoleIds.substring(0,saveSelectRoleIds.length-1);
		saveSelectRoleIds = (saveSelectRoleIds == "" || saveSelectRoleIds.substring(0,1) == ",") ? saveSelectRoleIds : "," + saveSelectRoleIds;
		$.ajax({
			url : "${ctx}/crmuser/ajax/updateRoleIdsById",
			data:{
				roleIds:saveSelectRoleIds,
				userId:saveUserId
			},
			type:"post",
			success:function(data){
				setWinStyle(roleWin,true);
				if(data == 1){
					Ext.Msg.alert("提示","保存成功！");
					store.reload();
				}else{
					alert("更新失败");
				}
			}
		});
	}
	//选择角色
	function selectRole(rowIndex){
		//$("#frisel_"+data.options[i].id).attr("class","fs_selected");
		//清空所有已选角色(将样式名为fs_selected的元素的样式移除即可)
		$(".fs_selected").attr("class","");
		var tmp = list.getAt(rowIndex);
		saveUserId = tmp.get("id");
		//首先获取该用户已有权限
		saveSelectRoleIds = tmp.get("roleIds");
		//saveSelectRoleIds = saveSelectRoleIds == "" ? "" : saveSelectRoleIds + ",";
		$.ajax({
			url : "${ctx}/crmuser/ajax/getRoleById",
			data:{
				roleIds:tmp.get("roleIds")
			},
			type:"post",
			success:function(data){
				eval("var data=" + data);
				var li = "";
				for(var i = 0; i < data.options.length; i++){
					$("#frisel_"+data.options[i].id).attr("class","fs_selected");
					li += getRoleHtml(data.options[i].id,data.options[i].name);
				}
				$("#frisel_selectList").html(li);
				if(!roleWin){
					roleWin = new Ext.Window({
						id:"roleWin",
						el:"role-win",
						title:"操作",
						layout:'fit',
						width:530,
						height:480,
						hidden:true,
						resizable:false,
						closeAction:'hide',
						plain: true,
						contentEl : "friendSelecter",
				        buttons: [
				        		{text:'保存',handler:  function(){
									updateRoleIdsById();//这里传参只一次有效，因为该窗体只生成一次
									}
								},
							    {text: '取消',handler: function(){roleWin.hide();}
								}]
					});
				}
				roleWin.show();
			}
		});
	}
	var store;
	Ext.onReady(function(){
    	store = new Ext.data.Store({
	       	proxy:new Ext.data.HttpProxy({
	       		url: '${ctx}/crmuser/ajax/list'
	       	}),
	       	//读取数据源用json方法(三种方法1.读取json用JsonReader,2读取数组使用ArrayReader3.读取XML用XmlReader)
	       	reader:new Ext.data.JsonReader({
				root:"root",
	           	//从数据库中读取的总记录数
	           	totalProperty: 'count',
	           	fields:[
	                    'id','userName','userTrueName','userPass','linkTel','mobilePhone','email','roleIds','roleName','userCityNo','cityNo',
	                    'cityName','state','lastLoginTime'
	                   ]
			})
		});
	
  		var bbar= new Ext.PagingToolbar({
	        pageSize: 25,
	        store: store,
	        loadMask: this.LoadMask,
	        displayInfo: true,
	        displayMsg: '当前为第[{0}]</span>条至第[{1}]条数据，共[{2}]条数据',
	        emptyMsg: "没有数据"
	    });
  		//var sm = new Ext.grid.CheckboxSelectionModel();//复选框
		var cm = new Ext.grid.ColumnModel([
          	{header: "用户名", width: 120, sortable: true, dataIndex: 'userName'},
          	{header: "联系电话", width: 120, sortable: true, dataIndex: 'linkTel'},
          	{header: "用户密码", width: 120, sortable: true, dataIndex: 'userPass'},
          	{header: "手机", width: 120, sortable: true, dataIndex: 'mobilePhone'},
          	{header: "email", width: 120, sortable: true, dataIndex: 'email'},
          	{header: "所属角色", width: 120, sortable: true, dataIndex: 'roleIds',
				renderer:function(value){
					//根据角色id 获取角色名称
					var roleName = "";
					for (var i = 0; i < roleList.length; i++) {
						if (value.indexOf("," + roleList[i][1] + ",") > -1) {
							roleName += roleList[i][0] + ",";
						}
					}
					return roleName == "" ? "" : roleName.substring(0,roleName.length - 1);
				}
			},
          	{header: "当前状态", width: 120, sortable: true, dataIndex: 'state',
          		renderer:function(value){
          			if(value == 0){
						return "<span style='color:gray'>离职</span>";
					}else{
						return "<span style='color:black'>在职</span>";
					}
        	  	}
          	},
          	{header: "最后登录时间", width: 120, sortable: true, dataIndex: 'lastLoginTime'},
          	{header: "操作", width: 120, sortable: true, dataIndex: 'id',
    		  id:"id",renderer:renderPromiseInfo,sortable:false}
    	]);
    	function renderPromiseInfo(value,cellmeta,record,rowIndex,columnIndex,store){
			cellmeta.attr =  'ext:qtitle="'  + "提示：" + '"';
			cellmeta.attr += 'ext:qtip="'  + "点击打开对应的承诺列表!" + '"';
			cellmeta.attr += 'ext:qwidth="150" ';
			var tmp = "<a style='color:blue;cursor:pointer' onclick='btnaddOrUpdateIssue_click(\"edit\","+rowIndex+",\"nleft\")'>更新</a>&nbsp;&nbsp;";
			tmp += "<a style='color:blue;cursor:pointer' onclick='selectRole(" + rowIndex + ")'>选择角色</a>&nbsp;&nbsp;";
			list = store;
			return tmp;
		}
		var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"加载数据中,请等待......",store:store,removeMask :true});
	    var grid= new Ext.grid.GridPanel({
	    	id:'grid2',
	    	layout : 'fit',
	    	//自动适应宽高
	        //autoWidth:true,
	    	//autoHeight : true,
	        width:document.body.clientWidth,
	        height:document.documentElement.clientHeight,
	    	//指定div的ID
	    	//el:'pageGrid',
	    	maskText : '正在加载中...',
	     	getLoadMask : function(){
	         	if(this.LoadMask){
	          		return this.LoadMask;
	         	}else{
	          		this.LoadMask = new Ext.LoadMask(Ext.getBody(),{msg:this.maskText,removeMask : true});
	          		return this.LoadMask;
	         	}
	        },
	        setMaskText : function(msg){
	        	this.maskText = msg;
	        	this.getLoadMask().msg = this.maskText;
	        },
     		store:store,
     		tbar : [
         		//'关键字：',{id:'keyword',name:'keyword',xtype : 'textfield',emptyText :'按type查询',width:"150"},
				'选择城市',new Ext.form.ComboBox({
        	 		id:'secUserCityNo',
		        	name:'secUserCityNo',
		        	hiddenId:'searchUserCityNo',
		        	hiddenName:'searchUserCityNo',
		        	store:userCityList,
         	 		valueField:'value',
          	 		displayField:'text',
          	 		emptyText : '请选择',
          	 		editable:false,
          	 		mode:'local',
          	 		listeners: {
	                	load: function() {
	                    	comboLocation.setValue(comboLocation.getValue());
	                	}
            		},
          	 		triggerAction:'all'
           		}),
         		'角色类型',new Ext.form.ComboBox({
        	 		id:'secRole',
		        	name:'secRole',
		        	hiddenId:'searchRole',
		        	hiddenName:'searchRole',
		        	store:new Ext.data.SimpleStore({
						fields:['text','value'],
						data:roleList
					}),
	        	 	/*new Ext.data.SimpleStore({
	        		 proxy:new Ext.data.HttpProxy({
				       		url: '${ctx}/ajax/'
				     }),
	        		 fields:['text','value'],
	        		 autoLoad:true
	        		 data : [['根据二维码获取优惠券信息','根据二维码获取优惠券信息'],
	        			 ['获取单个优惠券评论','获取单个优惠券评论'],
	        			 ['获取单个优惠券详细信息','获取单个优惠券详细信息'],
	        			 ['获取二级优惠数据','获取二级优惠数据'],
	        			 ['获取热门优惠券','获取热门优惠券'],
	        			 ['获取优惠券列表信息','获取优惠券列表信息']
	        			 ]
	        			 }),*/
         	 		valueField:'value',
          	 		displayField:'text',
          	 		emptyText : '请选择',
          	 		editable:false,
          	 		mode:'local',
          	 		listeners: {
	                	load: function() {
	                    	comboLocation.setValue(comboLocation.getValue());
	                	}
            		},
          	 		triggerAction:'all'
           		}),
         		'用户名',new Ext.form.TextField({
        	 		id:"searchUserName",
        	 		name:'searchUserName',
           	 		valueField:'value',
           	 		displayField:'text',
           	 		editable:false,
           	 		mode:'local',
           	 		triggerAction:'all'
           		}),
         	" ",goAction," ",addAction," ",delAction],
         	cm:cm,
         	//sm:sm,
         	//sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
         	viewConfig:{
          		forceFit: true
         	},  
         	frame:true,    
         	// 自动出现 expand/collapse toggle button, 上下收展的按纽   
         	titleCollapse: true, 
         	//collapsible: true,点击title也可以收展    
         	hideCollapseTool: true, 
         	//title:'用户投诉', // 表格标题    
         	header: false, 
         	// 不创建标题栏    
         	headerAsText: true, 
         	// 如果有标题栏, 隐藏标题栏    
         	iconCls:'icon-grid',  
         	//显示等待数据加载（loading）图标
         	loadMask: this.LoadMask,
         	//表格的工具栏    
         	/*tools:[ 
          	// 与title同一栏的按纽          
          	//{id:"save"},
          	{id:"help", 
          	handler:function(){
	          	Ext.Msg.alert('help','有问题？');}}, 
          	{id:"close",handler:function(){
     		Ext.Msg.alert('help','你想死啊');}}
           	// 按纽取值如下, close,minimize ,maximize ,restore ,gear ,pin ,unpin          
           	// toggle, down ,refresh ,minus ,plus ,help ,search ,save ,right ,left ,up  
          	],*/
          	//自带分页工具条
          	bbar: bbar
		});
		store.on('beforeload',function( store , options ){
			store.baseParams = {
          		searchRole:Ext.get("searchRole").dom.value,
          		searchUserName:Ext.getCmp("searchUserName").getValue(),
				searchUserCityNo:Ext.get("searchUserCityNo").dom.value
				//pageNum:getPageNum()
          	};
       	 });
   		 grid.render("pageGrid");
    	 store.load({
    		 params:{start:0,limit:25},
    		 callback:function(data,options,success){
	        	for (var i = 0; i < store.getCount(); i++){
					 //alert(data[i].get('dfName'));
    			 }  
	        	
			}}
    	 );
    });
	function getPageNum(){
		return Ext.getCmp("grid2").getBottomToolbar().cursor + 1;
	}
	var goAction = new Ext.Action({
	    text:"<img src='${ctx}/images/query.png'>",
	    tooltip:'查询用户',
	    handleMouseEvents : false,
	    pressed : true,
	    handler: function(){
			Ext.getCmp("grid2").getStore().removeAll();
	      	Ext.getCmp("grid2").getStore().load("/ajax/listApiTracLog.do");
	    }
    });
    var addAction = new Ext.Action({
	    text:"<img src='${ctx}/images/add.png'>",
	    tooltip:'添加用户',
	    handleMouseEvents : false,
	    pressed : true,
	    handler: function(){
			btnaddOrUpdateIssue_click('add',null,'nleft');
			//Ext.getCmp("grid2").getStore().removeAll();
	      	//Ext.getCmp("grid2").getStore().load("123123.do");
	    }
    });
    var delAction = new Ext.Action({
	    text:"<img src='${ctx}/images/delete.png'>",
	    tooltip:'删除用户',
	    handleMouseEvents : false,
	    pressed : true,
	    handler: function(){
			var selections = Ext.getCmp("grid2").getSelectionModel().getSelections();
			if(selections.length == 0 ){
			 	Ext.Msg.alert('错误','请选择要删除的数据');
				return ;
			}
			var ids = "";
			for(var i=0;i<selections.length;i++){
				ids += selections[i].get("id") + ",";
			}
			listDelete(ids.substring(0,ids.length-1));
	    }
    });
</script>
</head>

<body>
	
	<div id="pageGrid"></div>
	<div id="role-win" class="x-hidden">
		<div class="layer_global friend_sel" id="friendSelecter" style="display: block; background-color: white;">
			<div class="layer_global_main">
				<div id="frisel_dropHandler" class="layer_global_title">
					<h3>
						<span class="jian">&gt;</span>选择好友
					</h3>
					<button class="bt_close" onclick="FriendSelecter.close()"
						title="关闭">
						<span class="none">╳</span>
					</button>
				</div>
				<div class="layer_global_cont">
					<!-- QQ好友 开始 -->
					<div class="gb_friend_selector_mod left">
						<div class="gb_friend_selector">
							<div class="gb_friend_selector_tit">
								<strong>所有角色</strong>
							</div>
							<div id="frisel_search" class="gb_friend_selector_cont gb_friend_selector_search">
								<!-- 搜索框 开始 -->
								<!--
								<div class="gb_friend_selector_search">
									<div class="fs_search">
										<input id="frisel_keyword" type="text" class="fs_hint"
											value="查找好友" onfocus="FriendSelecter.initSearch();"
											onkeyup="FriendSelecter.search()">
										<a class="fs_search_b" href="javascript:;" title="查找好友">搜索</a>
										<a class="fs_state"
											href="javascript: FriendSelecter.cancelSearch()" title="关闭搜索">关闭搜索</a>
									</div>
								</div>
								-->
								<!-- 角色列表 -->
								<div class="gb_friend_selector_list">
									<ul id="frisel_allList" class="fs_fold">
										<#list roleList as role>
										<li id="frisel_${role.id?c}" onclick="addRoleHtml(${role.id},'${role.name!}')">
											<a href="javascript:;" hidefocus="true" class="fs_nor" title="${role.roleDesc!}">${role.name!}</a>
											<span class="fs_state">已选中</span>
										</li>
										</#list>
									</ul>
									<!--
									<ul id="frisel_searchList" class="fs_fold fs_result" style="display: none;"></ul>
									<dl id="frisel_friendList" class="fs_fold fs_all_friend" style="display: block;">
										<dd style="display: block">
											<ul class="list_friend">
												<#list roleList as role>
												<li id="frisel_${role.id?c}" onclick="addRoleHtml(${role.id},'${role.name!}')">
													<a href="javascript:;" hidefocus="true" class="fs_nor" title="${role.roleDesc!}">${role.name!}</a>
													<span class="fs_state">已选中</span>
												</li>
												</#list>
											</ul>
										</dd>
									</dl>
									-->
								</div>
							</div>
						</div>
					</div>
					<!-- 已选好友 开始 -->
					<div class="gb_friend_selector_mod right">
						<div class="gb_friend_selector">
							<div class="gb_friend_selector_tit">
								<strong>已选角色 <span id="frisel_numTips">（0/10）</span>
								</strong>
							</div>
							<div class="gb_friend_selector_cont">
								<div class="gb_friend_selector_list">
									<ul id="frisel_selectList" class="fs_fold">
										<!--<li class="fs_del">
											<a class="fs_nor" hidefocus="true">   此6位号出售`</a>
											<a class="fs_state" onclick="FriendSelecter.del(377481,0)">删除</a>
										</li>-->
									</ul>
								</div>
							</div>
						</div>
					</div>
					<div class="wrap_tips">
						<p id="frisel_tips" class="tips_text"></p>
						<div class="bt_wrap">
							<a id="frisel_yes" href="javascript:FriendSelecter.close();"
								class="bt_small"><strong>确 定</strong>
							</a>
							<a id="frisel_cancel" href="javascript:FriendSelecter.close()"
								class="bt_small"><strong>关闭</strong>
							</a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- 新增/修改 -->
	<div id="hello-win" class="x-hidden">
		<div id="nleft" class="nleft" style="background: white;">
			<table width="482" border="0" cellpadding="0" cellspacing="0">
				<tbody>
					<tr>
						<td width="100" height="30" align="center">用户名</td>
						<td align="center"><input type="text" id="userName" name="userName"/></td>
						<td width="100" align="center">真实姓名</td>
						<td><input type="text" id="userTrueName" name="userTrueName"/></td>
					</tr>
					<tr bgcolor="#ECF1FA">
						<td width="100" height="30" align="center">联系电话</td>
						<td align="center">
							<input type="text" id="linkTel" name="linkTel"/>
						</td>
						<td align="center">手机</td>
						<td>
							<input type="text" id="mobilePhone" name="mobilePhone"/>
						</td>
					</tr>
					<tr>
						<td width="100" height="30" align="center">电子邮件</td>
						<td align="center">
							<input type="text" id="email" name="email" />
						</td>
						<td align="center">当前状态</td>
						<td>
							<select id="state" name="state" style="width:133px">
								<option selected="selected" value="1">在职</option>
								<option value="0">离职</option>
							</select>
						</td>
					</tr>
					<tr>
						<td width="100" height="30" align="center">所属城市</td>
						<td align="center">
							<select id="userCityNo" name="userCityNo" style="width:133px"></select>
						</td>
						<td></td>
						<td></td>
					</tr>
					<tr bgcolor="#ECF1FA">
						<td width="100" height="30" align="center">设置城市</td>
						<td colspan="3" style="padding-left:3px;">
							<!--<select id="cityNo" name="cityNo" style="width:133px">
								<option selected="selected" value="21">上海</option>
								<list (SESSION_USER.cityNo)?split(",") as city>
							</select>-->
							<#list cityList as city>
								<#if (SESSION_USER.cityNo?index_of("," + city.cityno + ",")) &gt; -1>
								<input type="checkbox" id="${city.cityno}" name="cboCityNo" value="${city.cityno}"><label for="${city.cityno}">${city.cityname}</label>
									<#if (city_index+1)%7 == 0>
										<br /><br />
									</#if>
								</#if>
							</#list>
							<input type="checkbox" id="all" name="cboAll" onclick="reverseAllSelect(this)"><label for="all">选择全部</label>
						</td>
						<!--<td></td>
						<td></td>-->
					</tr>
				</tbody>
			</table>
		</div>
		<!--//------------------------------------------------------------------------------------------------------->
	</div>
	<script type="text/javascript">
		//根据cityNo 获取cityName
		function getCityName(cityNo){
			for (var i = 0; i < cityList.length; i++) {
				if (cityNo == cityList[i][1]) {
					return cityList[i][0];
				}
			}
			return "";
		}
		//为用户所属城市赋值
		function setCity(){
			var userCityNo = "${SESSION_USER.cityNo!}";
			var arr = userCityNo.split(",");
			var sel = document.getElementById("userCityNo");
			for(var i=1;i<arr.length;i++){
				if(arr[i] != ""){
					sel.options.add(new Option(getCityName(arr[i]),arr[i]));
				}
			}
		}
		setCity();
	</script>
</body>
</html>
